home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / psion / src.doc / unsorted / mcfile.doc < prev    next >
Text File  |  1986-12-15  |  10KB  |  264 lines

  1. Psion Proprietary File Format
  2.  
  3.  
  4. 1    MC/HC/Series 3 data files.
  5.  
  6.     The   files  used   by  the   Personal  Database   and  Diary applications  on the MC400 and MC200 are OPL-compatible. That is,  they can be created, opened, edited and appended to from within   the  users'   own  OPL   programs.  The   files  are EPROM-friendly  in that they allow the deletion of records in a file stored on an EPROM device.
  7.  
  8.     The  files consist of Type Length Value (TLV) records and are made up as follows:
  9.  
  10.  
  11.     1.1    A standard file signature header.
  12.  
  13.         This  is the same for all OPL compatible files. It is made up as follows:
  14.  
  15.             The null-terminated string "OPLDatabaseFile"
  16.  
  17.             A file version number - e.g. 1.10f
  18.  
  19.             The offset to the start of the first record
  20.  
  21.             An OPL runtime version number - e.g. 1.10f
  22.  
  23.  
  24.     1.2    Field Structure Record.
  25.  
  26.         All TLV records start with a word containing:
  27.  
  28.             The record type in the most significant nibble.
  29.  
  30.             The length in the remaining three nibbles.
  31.  
  32.         This record must be the  first  record  in  the  file. It specifies the number  and  types  of  the  fields  in the following records. The  length of  the record  defines the number  of fields allowed. The body of the record consists of  a sequence of bytes specifying the type of each field. These types are:
  33.  
  34.             0    OPL integer         (WORD)
  35.             1    OPL long integer    (LONG)
  36.             2    OPL floating point  (DOUBLE)
  37.             3    OPL leading byte count string
  38.  
  39.         OPL  and the Personal Database (but NOT the Diary) accepts short  records, where one  or more of  the trailing fields are  not  present.  The  fields  which are  present  must correspond,  in order, with  the sequence of  types in the Field Structure Record.
  40.  
  41.  
  42.  
  43.  
  44.  
  45.     1.3    Type 1 TLV records.
  46.  
  47.         There will  be a sequence of  these records containing the data.
  48.  
  49.  
  50.     1.4    Type 3 and above TLV records.
  51.  
  52.         There may be records of this type in the file (for example a  voice record in a Diary  file or the descriptive record in a Personal Database file). Records of this type are not documented here.
  53.  
  54.  
  55.     1.5    Database file example.
  56.  
  57.         The following  is an example  of how a Database file containing one entry would be held:
  58.  
  59.  
  60.         File Signature
  61.  
  62.         4f 50 4c 44 61 74 61 62 61 73 65 49 69 6c 65 00
  63.         (O  P  L  D  a  t  a  b  a  s  e  F  i  l  e  Null)
  64.  
  65.         10 0f               file version
  66.         00 16               offset
  67.         10 0f               OPL runtime version
  68.         
  69.         
  70.         Field Structure Record
  71.  
  72.         2020                field structure
  73.         03                OPL leading byte count string
  74.         03                OPL leading byte count string
  75.         03                OPL leading byte count string
  76.         03                OPL leading byte count string
  77.         .
  78.         .                (up to 32 text fields)
  79.         .
  80.         03                OPL leading byte count string
  81.         03                OPL leading byte count string
  82.         
  83.  
  84.         Example Data Record
  85.  
  86.         102d
  87.         0d 42 52 20 73 74 61 74 69 6f 6e 3a 20 20
  88.         (   B  R     s  t  a  t  i  o  n  :      )  
  89.         10 5a 6f 6e 65 3a 20 20 20 20 20 20 20 20 20 20 20
  90.         (   Z  o  n  e  :                                 )
  91.         0d 54 72 61 76 65 6c 20 72 6f 75 74 65 3a
  92.         (   T  r  a  v  e  l     R  o  u  t  e  :)
  93.  
  94.  
  95.  
  96.  
  97. 2    MC Diary files.
  98.  
  99.     The following is an example of how a Diary file containing one entry would be held:
  100.  
  101.  
  102.     File Signature
  103.  
  104.     4f 50 4c 44 61 74 61 62 61 73 65 49 69 6c 65 00
  105.     (O  P  L  D  a  t  a  b  a  s  e  F  i  l  e  Null)
  106.  
  107.     10 0f               file version
  108.     00 16               offset
  109.     10 0f               OPL runtime version
  110.  
  111.  
  112.     Field Structure Record
  113.  
  114.     2006                field structure
  115.     00                  day number    (WORD)
  116.     00                  time/index    (WORD)
  117.     00                  duration    (WORD)
  118.     00                  alarm time    (WORD)
  119.     00                  flags        (WORD)
  120.     03                  text        (STRING)
  121.  
  122.  
  123.     Example Data Record
  124.  
  125.     1016                diary record $016 bytes long
  126.     8087                1st February 1990 (a)
  127.     8258                10.00am (b)
  128.     003c                1 hour duration = $3c minutes
  129.     0249                09.45am (c)
  130.     0000                no alarm, no voice (d)
  131.     0b 66 69 72 73 74 20 65 6e 74 72 79
  132.     (   f  i  r  s  t     e  n  t  r  y)
  133.                         byte counted = $0b
  134.  
  135.  
  136.     Notes:
  137.  
  138.     a)    The day number is days since 1/1/1900 (= day 0). The first legal day is 5/1/1970. The last is 3/6/2079.
  139.  
  140.     b)    The  top bit  of the  time field  is set  for timed entries and  clear for  untimed entries.  The rest  of the field  is the start time in minutes or the index number of an untimed entry.
  141.  
  142.     c)    The  alarm time is in minutes.  It must be, sensibly, less than  or equal to the time start time. The value is arbitrary if the alarm flag is clear.
  143.  
  144.  
  145.  
  146.     d)    The second byte of the  flags  field  is  unused  and  may contain  random data. Bit 0 ($01) is set for an alarm. Bit 1 ($02) is  used  internally  to  temporarily  disable  an alarm. Bit 1 should be clear if bit 0 is set, but may have any value if bit 0 is clear. Bit 2 ($04) is set for voice. The remaining bits are not used.
  147.  
  148.  
  149.     2.1.    Diary file access from OPL
  150.  
  151.         The  following line of code will open  the file for use in an OPL program with the logical name of 'A'.
  152.  
  153. OPEN "LOC::M:\diary.dry",A,day%,time%,len%,alarm%,flags%,txt$
  154.  
  155.         Loading the individual fields  with  appropriate  values  and then executing an  UPDATE or  APPEND will  allow you  to edit existing records (Diary  entries) and  add new  ones. Records deleted  with the OPL ERASE command  will be removed from the Diary file. All  of the  OPL file  handling commands  such as FIRST, NEXT, LAST, FIND, etc will apply.
  156.  
  157.         It should be noted  that the  fields such  as day  number are stored as unsigned words. When OPENed as integers, the values will  be represented as large negative numbers due to the top bit of the word being  set.  When  loading  the  fields  with values to  be  written  to  the  file,  users  may  encounter problems when  trying to load a field  such as the day number field with  a large positive number of  days i.e. a number of days  over 32767. One approach in this circumstance is to use the following method:
  158.  
  159.     tdays&  = 39000    /* too large for an integer */
  160.     A.days% = PEEKW(ADDR(tdays&)) 
  161.     .
  162.     .  rest of code
  163.     .
  164.     UPDATE
  165.     CLOSE
  166.     .
  167.     .
  168.     .
  169.     etc.
  170.  
  171.  
  172.  
  173. 3    Series 3 Agenda files
  174.  
  175.     Series 3 Agenda files are very similar indeed to MC Diary files. However, the following differences apply:
  176.  
  177.     3.1    Field Structure Record.
  178.  
  179.         2005        field structure
  180.         00        day number    (WORD)
  181.         00        duration    (WORD)
  182.         00        time        (WORD)                                00        alarm time    (WORD)
  183.         03        text        (STRING)
  184.     3.2    Timed and untimed items.
  185.  
  186.         -    The day number is the number of days since the 1/1/1900 (=day 0). The first legal day is 1/1/1980, the last legal day is the 31/12/2049.
  187.  
  188.         -    duration, time and alarm time are all stored in minutes.
  189.  
  190.         -     The MSB of time (i.e. $8000) is a flag that indicates whether the item is timed or untimed. If the flag is set then the item is untimed, if clear then the item is timed.
  191.  
  192.         -     To extract the time from the time field it must be ANDed with $7fff to remove the MSB.
  193.  
  194.         -     The LSB of duration (i.e. $1) is a flag that indicates whether the item has an alarm attached. If the flag is set then the item has no alarm attached, if clear then the item has an alarm attached.
  195.  
  196.         -     To extract the duration from the duration field, divide by 2 which removes the LSB and shifts down the duration.
  197.  
  198.         -     If the item is untimed then the time field contains the day note slot number (i.e. 1 to n and its MSB must be set). The duration field contains 0 if an alarm is attached or 1 if no alarm is attached.
  199.  
  200.         -     The end time of a timed item (i.e time + duration) must be less than 24 * 60 = 1440 minutes.
  201.  
  202.         -     For timed items, the alarm time is an alarm pre time and is calculated as follows:
  203.  
  204.             Pre time to Agenda internal alarm format:
  205.  
  206.             (23 * 60 + 59) + alarm pre time - time
  207.  
  208.             Agenda internal alarm format to pre time:
  209.  
  210.             time - (23 * 60 + 59) + alarm time
  211.  
  212.         -     For untimed items, the alarm time is calculated as follows:
  213.  
  214.             Pre time to Agenda internal alarm format:
  215.  
  216.             (days previous*(24*60))-((23*60+59)-alarm time)
  217.  
  218.             Agenda internal alarm format to days previous:
  219.  
  220.             alarm time / (24 * 60)
  221.  
  222.             Agenda internal alarm format to alarm time:
  223.  
  224.             (23 * 60 + 59) - (alarm time modulus (24*60))
  225.  
  226.         -    If the item does not have an alarm, the alarm time field should contain -1.
  227.         -    The text field is stored as a leading byte count string and its length must be less than 64 characters.
  228.  
  229.  
  230.     3.3    Todo items.
  231.  
  232.         -    Todo items have a day number of $ffff and must be stored as timed items. As such, the MSB of the time field must be clear.
  233.  
  234.         -    The time field contains the item priority (i.e. 1 to 9).
  235.  
  236.         -    The duration field contains a secondary key which orders Todo items within priority.
  237.  
  238.         -    Todo items cannot have alarms attached.
  239.  
  240.  
  241.     3.4    Repeat items.
  242.  
  243.         -    Timed and untimed repeat items are stored in exactly the same way as normal timed and untimed items, except that they have a day number of $fffe.
  244.  
  245.         -    The specific repeat details are stored at the end of the text field and have the following format:
  246.  
  247.                 type            (BYTE)
  248.                 interval        (BYTE)
  249.                 start day number    (WORD)
  250.                 end day number    (WORD)
  251.  
  252.         -    The type field can take the following values:
  253.  
  254.                 repeat yearly            = 0
  255.                 repeat monthly by date    = 1
  256.                 repeat monthly by day    = 2
  257.                 repeat weekly            = 3
  258.                 repeat daily            = 4
  259.                 repeat workdays        = 5
  260.  
  261.         -    The start day number and end day number are stored as the number of days since 1/1/1900 (=day 0).
  262.  
  263.         -    Setting the end day number field to 0 means the item will repeat forever.
  264.